#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <Dynamics/Boundary/fixed_freedom_cuda.h>
#include <string>
using namespace PhysLeo;
namespace py = pybind11;

template<typename T>
static void declareFixedFreedomCpu(py::module &mod, const std::string &typestr)
{
    using class_type = FixedFreedomCpu<T>;
    auto pyclass_name = std::string("FixedFreedomCpu") + typestr;
    py::class_<class_type, std::shared_ptr<class_type>>cls(mod, pyclass_name.c_str());

    cls.def(py::init());
    cls.def("allocateResource", &class_type::allocateResource);
    cls.def("clearFixedFreedom", &class_type::clearFixedFreedom);
    cls.def("setFixedFreedom", &class_type::setFixedFreedom);
}

template<typename T>
static void declareFixedFreedomCuda(py::module &mod, const std::string &typestr)
{
    using class_type = FixedFreedomCuda<T>;
    using base_type = FixedFreedomCpu<T>;
    auto pyclass_name = std::string("FixedFreedomCuda") + typestr;
    py::class_<class_type, base_type, std::shared_ptr<class_type>>cls(mod, pyclass_name.c_str());

    cls.def(py::init());
    cls.def("clearFixedFreedom", &class_type::clearFixedFreedom);
    cls.def("setFixedFreedom", &class_type::setFixedFreedom);
}

void initFixedFreedom(py::module &m)
{
    declareFixedFreedomCpu<float>(m, std::string("F"));
    declareFixedFreedomCpu<double>(m, std::string("D"));

    declareFixedFreedomCuda<float>(m, std::string("F"));
    declareFixedFreedomCuda<double>(m, std::string("D"));
}
